<template>
	<view>
		<cu-custom class="text-Black" bgColor="bg-red" :isBack="true"><block slot="backText"></block>
			<block slot="content">授权管理</block>
		</cu-custom>
		<block v-if="list &&list.length > 0">
			<view class="cu-list menu margin-top">
				<view class="cu-item " v-for="(item,index) in list" :key="index">
					<view class="content">
						<text v-if="item.oauth_client=='wechat'">微信</text>
						<text v-if="item.oauth_client=='wechatMp'">微信小程序</text>
						<text class="text-gray text-sm">({{item.oauth_client_user_id}})</text>
					</view>
					<view class="action">
						<view class="cu-btn line-red round sm" @tap="cancelAuth(item.id)">解除绑定</view>
					</view>
				</view>
			</view>
		</block>
		<block v-else>
			<view class="empty padding-xl text-gray text-center">暂无授权记录</view>
		</block>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				list: null,
			}
		},
		onLoad(options) {
			if (this.$common.loginAuth(true)) {
				this.getList()
			}
		},
		methods: {
			getList() {
				this.$http
					.get('auth_list')
					.then((response) => {
						this.list = response.data.data
					})
					.catch((response) => {})
			},
			cancelAuth(id) {
				this.$http
					.delete('auth_list', null, id)
					.then((response) => {
						this.$common.showSuccess('解除成功')
						this.getList()
						console.log(response)
					})
					.catch((response) => {})
			},
		},
	}
</script>

<style>
</style>
